extends StaticBody2D

@export_enum("mushroom","flower","coin") var select_type:String
const MUSHROOM = preload("res://scenes/mushroom.tscn")
const FLOWER = preload("res://scenes/flower.tscn")

var has_spwan_child:bool = false

func _ready():
	pass

func set_empty():
	if has_spwan_child:
		return
	$AnimatedSprite2D.play("empty")
	spwan_child()
	
func spwan_child():
	var child = load("res://scenes/%s.tscn" %select_type).instantiate()
	child.global_position = global_position
	get_tree().root.add_child(child)
	has_spwan_child = true


func _on_area_2d_body_entered(body):
	if body.is_in_group("player"):
		set_empty()
	pass # Replace with function body.
